#include <QtGui/QApplication>
#include <QDebug>
#include "mainwindow.h"
#include "logger.h"
#include "my_defs.h"
#include "appmanager.h"

int main(int argc, char *argv[])
{
    // For correct encoding
    QTextCodec *codec = QTextCodec::codecForName("UTF-8");
    QTextCodec::setCodecForCStrings(codec);

    QApplication a(argc, argv);

    // Creating logger instance
    Logger::CreateInstance();
    LOG( "Main", "Початок роботи програми", "" );

    // Creating application manager instance
    AppManager::CreateInstance();

    appManager->mainWindow()->show();

    // Run app loop
    int result = a.exec();

    // Freeing application manager instance
    AppManager::DestroyInstance();

    // Freeing logger instance
    LOG( "Main", "Завершення роботи програми", QString("З кодом <b>%1</b>").arg(result, 3, 10) );
    Logger::DestroyInstance();

    return result;
}
